package com.bgq.trxauth.controller;

import com.bgq.trxauth.mapper.AuthMapper;
import com.bgq.trxauth.model.Auth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class DataController {
    @Autowired
    private AuthMapper authMapper;

    @GetMapping(value = "test")
    public String testApi() {
        return "hello, ok";
    }



    @GetMapping(value = "testInsert")
    public String testInsert(@RequestParam Long idLong) {
        Auth auth = new Auth();
        auth.setId(idLong);
        auth.setUserId("123awda-cefa");
        auth.setCreateTime(new Date());
        auth.setUpdateTime(new Date());
        auth.setPayRecordRefId("2121212");
        auth.setAuthCode("chl");

        int insertAuthEffective = authMapper.insert(auth);
        System.out.println("insertAuthEffective: " + insertAuthEffective);

        return "testInsert ok";
    }

}
